package tmhprediction.optimization;

import java.io.File;

import tmhprediction.classification.TMHClassifier;
import tmhprediction.eval.TMHResidueEvaluator;

public class GridSearchRunner
{
	
	public static void main(String[] args) throws Exception
	{
		double c = Double.valueOf(args[0]);
		double g = Double.valueOf(args[1]);
		String outFolder = args[2];
		String inFolder = args[3];
		
		c = Math.pow(2.0, c);
		g = Math.pow(2.0, g);
		
		File o = new File(outFolder);
		o.mkdir();
		
		String set1 = inFolder+"/features_manual_0.arff";
		String set2 = inFolder+"/features_manual_1.arff";
		String set3 = inFolder+"/features_manual_2.arff";
		
		System.out.println("First combination");
		doIt(set1, set2, g, c, outFolder,1);
		System.out.println("Second combination");
		doIt(set2, set3, g, c, outFolder,2 );
		System.out.println("Third combination");
		doIt(set3, set1, g, c, outFolder,3 );
		
	}
	
	static void doIt(String trainingSet, String testSet, double gamma, double cost, String outFolder, int index) throws Exception
	{
		TMHClassifier classifier = new TMHClassifier(trainingSet, testSet, gamma, cost);
		classifier.createOutputFromEvaluation(outFolder+"/"+index+"_evaluateModel");
		classifier.saveModel(outFolder+"/"+index+"_model.svm");
		TMHResidueEvaluator.calcPerResidueScores(classifier.createResultMap() ,outFolder+"/"+index+"_scores");
	}
	

}
